<template>
	<view>
		<view class="list flex justify-center">
			<view class="list-box">
				<view class="list-box-item" v-for="(item,index) in list" :key="index">
					<view class="list-box-item-h" v-if="item.type==2">
						扣分：{{item.lastCreditScore - item.nextCreditScore}}
					</view>
					<view class="list-box-item-hs" v-else>
						加分：{{item.nextCreditScore - item.lastCreditScore}}
					</view>
					<view class="list-box-item-title" v-if="item.type==2">
						信用分变化：当前{{item.lastCreditScore}}分,扣除{{item.lastCreditScore - item.nextCreditScore}}分,最新信用分{{item.nextCreditScore}}分
					</view>
					<view class="list-box-item-title" v-else>
						信用分变化：当前{{item.lastCreditScore}}分,增加{{item.nextCreditScore - item.lastCreditScore}}分,最新信用分{{item.nextCreditScore}}分
					</view>
					<view class="list-box-item-title">
						原因：{{item.reason}}
					</view>
					<view class="list-box-item-title">
						修改时间：{{item.createTime}}
					</view>
				</view>
			</view>
		</view>
		<empty v-if="list.length==0" />
	</view>
</template>

<script>
	import empty from '../../components/empty.vue'
	export default {
		components:{
			empty
		},
		data() {
			return {
				list:[],
				page:1,
				limit:10,
				pages:1
			};
		},
		onLoad() {
			uni.showLoading({
				title:'加载中...'
			})
			this.getList()
		},
		//下拉刷新
		onPullDownRefresh() {
			this.page = 1
			this.getList()
		},
		//上拉加载更多
		onReachBottom() {
			if(this.page < this.pages){
				this.page += 1
				this.getList()
			}
		},
		methods:{
			//获取信用列表
			getList(){
				let data = {
					page:this.page,
					limit:this.limit
				}
				this.$Request.getT('/app/creditRecord/getCreditRecordList',data).then(res=>{
					uni.stopPullDownRefresh()
					uni.hideLoading()
					if(res.code == 0){
						this.pages = res.data.pages
						if(this.page == 1){
							this.list = res.data.records
						}else{
							this.list = [...this.list,...res.data.records]
						}
					}else{
						uni.showToast({
							title:res.msg,
							icon:'none'
						})
					}
				})
			},
		},
	}
</script>

<style lang="scss">
	page {
		background: #F5F5F5;
	}
	.list{
		width: 100%;
		.list-box{
			width: 686rpx;
			.list-box-item{
				width: 100%;
				// height: 200rpx;
				border-radius: 16rpx;
				background-color: #ffffff;
				margin-top: 20rpx;
				padding: 20rpx 20rpx;
			}
			.list-box-item-h{
				color: red;
				font-weight: bold;
			}
			.list-box-item-hs{
				color: green;
				font-weight: bold;
			}
			.list-box-item-title{
				margin-top: 10rpx;
				color: #999999;
			}
			
		}
	}
</style>